package com.ytjj.qmyx.supplychain.api.controller;

import com.ytjj.qmyx.supplychain.common.api.CommonResult;
import com.ytjj.qmyx.supplychain.mapper.entity.YxProductAttribute;
import com.ytjj.qmyx.supplychain.service.ProductAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品属性管理
 */
@RestController
@RequestMapping("/productAttribute")
public class ProductAttributeController {

    @Autowired
    private ProductAttributeService productAttributeService;

    /**
     * 新增编辑
     */
    @PostMapping("/addOrEdit")
    public CommonResult addOrEdit(@RequestBody YxProductAttribute request){
        return productAttributeService.addOrEdit(request);
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    public CommonResult list(@RequestParam(value = "id", required = false) Integer id,
                             @RequestParam(value = "attributeName", required = false) String attributeName,
                             @RequestParam(value = "attributeType", required = false) Integer attributeType,
                             @RequestParam(value = "status", required = false) Integer status,
                             @RequestParam(value = "pageNum", defaultValue = "1", required = false) Integer pageNum,
                             @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize) {
        return productAttributeService.list(id, attributeName, attributeType, status, pageNum, pageSize);
    }

    /**
     * 移除
     */
    @GetMapping("/delete")
    public CommonResult delete(@RequestParam Integer id){
        return productAttributeService.delete(id);
    }
}
